namespace IAM.Interface.Model
{
    using IAM.Interface.Common;
    using IAM.Interface.Model.Interface;
    using System;
    using System.Text;

    [Serializable]
    public class ResponseData : AbstractConvertObject, IConvertXml
    {
        private DateTime _responsetime = DateTime.Now;
        private string _returnmessage = "";
        private int _statuscode = 200;
        private string _transactionid = "";

        public override object ConvertToObject()
        {
            this.TransactionID = EnDeCoding.Decode(this.CurrentXmlNode.Attributes["TransactionID"].InnerText);
            this.ResponseTime = Convert.ToDateTime(this.CurrentXmlNode.Attributes["ResponseTime"].InnerText);
            this.StatusCode = int.Parse(this.CurrentXmlNode.Attributes["StatusCode"].InnerText);
            this.ReturnMessage = EnDeCoding.Decode(this.CurrentXmlNode.Attributes["ReturnMessage"].InnerText);
            return this;
        }

        public DateTime ResponseTime
        {
            get
            {
                return this._responsetime;
            }
            set
            {
                this._responsetime = value;
            }
        }

        public string ReturnMessage
        {
            get
            {
                return this._returnmessage;
            }
            set
            {
                this._returnmessage = value;
            }
        }

        public int StatusCode
        {
            get
            {
                return this._statuscode;
            }
            set
            {
                this._statuscode = value;
            }
        }

        public string TransactionID
        {
            get
            {
                return this._transactionid;
            }
            set
            {
                this._transactionid = value;
            }
        }

        public string XML
        {
            get
            {
                return (this.XMLBoday + this.XMLFinis);
            }
        }

        public string XMLBoday
        {
            get
            {
                StringBuilder _xml = new StringBuilder();
                _xml.Append("<ResponseData");
                _xml.Append(" TransactionID=\"" + EnDeCoding.Encode(this.TransactionID) + "\"");
                _xml.Append(" ResponseTime=\"" + this.ResponseTime + "\"");
                _xml.Append(" StatusCode=\"" + this.StatusCode.ToString() + "\"");
                _xml.Append(" ReturnMessage=\"" + EnDeCoding.Encode(this.ReturnMessage) + "\"");
                _xml.Append("  >");
                return _xml.ToString();
            }
        }

        public string XMLFinis
        {
            get
            {
                return "</ResponseData>";
            }
        }
    }
}
